﻿<?php 
require_once "Model.php";
require_once "Common/connDB.php";
	class goodsModel extends Model{
		public function __construct(){
			parent::__construct();
		}
		 function dologins(){
      
       $u=$_POST["uname"];
       $p=$_POST["password"];
       $sql="select * from users where uname='$u' and password=md5('{$p}')";
       echo $sql;
       $data1=$this->conn->query($sql);
       // var_dump($data1);
       if(!$data1==false){
        var_dump($data1);
       $num=count($data1);
        echo $num;
      if($num>0)
      {
        
      session_start();
      
      $_SESSION["user"]=$u;
      // echo "<br>".$_SESSION["desingerID"].$_SESSION["desinger"]."<br>";
      }
    }
      return $data1;
 }
		public function getgoodstype(){
		
			$sql="select * from goodstype";
			$data=$this->conn->query($sql);
			return $data;
		}
		
		public function getgoods1(){
		
			$sql="select * from goods where tid=(select tid from goodstype where typename='流行') limit 6";
			$data= $this->conn->query($sql);
			return $data;
			
		}
		public function getgoods2(){		
			$sql="select * from goods where tid=(select tid from goodstype where typename='摇滚') limit 6";
			$data= $this->conn->query($sql);
			return $data;	
		}
		public function getgoods3(){		
			$sql="select * from goods where tid=(select tid from goodstype where typename='民谣') limit 6";
			$data= $this->conn->query($sql);
			return $data;	
		}

		public function getgoods4(){		
			$sql="select * from goods where tid=(select tid from goodstype where typename='怀旧') limit 6";
			$data= $this->conn->query($sql);
			return $data;	
		}
		public function getgoods5(){		
			$sql="select * from goods where tid=(select tid from goodstype where typename='治愈') limit 6";
			$data= $this->conn->query($sql);
			return $data;	
		}
		// public function getTopHit(){
		// 	$sql="select * from goods   order by adddate desc   limit 4";
		// 	$data = $this->conn->query($sql);
		// 	return $data;
		// }
		// public function getTopDown2(){			
		// 	$sql="select * from goods   order by adddate desc   limit 4";	
		// 	$data = $this->conn->query($sql);
		// 	return $data;
		// }

		// public function getTopDown(){			
		// 	$sql="select * from goods   order by adddate desc   limit 4";	
		// 	$data = $this->conn->query($sql);
		// 	return $data;
		// }
		
		function getgoodstypename(){

      $tid = $_GET['tid'];
      $sql0="select * from goodstype where tid=$tid";
      // var_dump($sql0);
      // echo $sql0;
      $result0 = mysql_query($sql0) or die('查询失败！'.mysql_error());
      $row0 = mysql_fetch_assoc($result0);
      $sql = "select * from goods where tid={$tid}";
      // echo $sql;
      $data9=$this->conn->query($sql);
      return $data9;

     }
		public function getTypegoods(){
			$tid = $_GET['tid'];
			$sql = "select * from goods where tid={$tid}";
			$data = $this->conn->query($sql);
			return $data;
		}

		public function getgoodsContentbyID(){
            $gid=$_GET['gid'];
            $sql="select * from goods where gid=$gid";
            $data=$this->conn->query($sql);
            return $data;
    } 

        public function getgoodstype2(){
            $sql3="select * from goodstype";
            $data=$this->conn->query($sql3);
            return $data;
     }
     			public function dologin(){
				
			}

		
	}

 ?>